﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:WPF="clr-namespace:Tools.WindowsT.WPF"
                    xmlns:local="clr-namespace:Tools.WindowsT.WPF.DialogsT"
                    xmlns:c="clr-namespace:Tools.WindowsT.WPF.ConvertersT"
                    xmlns:i="clr-namespace:Tools.WindowsT.IndependentT"
     >
    <ControlTemplate TargetType="{x:Type local:ProgressMonitorImplementationControl}" x:Key="ProgressMonitorImplementationControlDefaultTemplate">
        <ControlTemplate.Resources>
            <c:CompareConverter x:Key="CompareConverter"/>
            <i:ProgressBarStyle x:Key="Indefinite">Indefinite</i:ProgressBarStyle> 
        </ControlTemplate.Resources>
        <Grid Width="auto" Height="auto" Margin="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
            <TextBlock Name="PART_MainInfo" Grid.Column="0" Grid.Row="0" HorizontalAlignment="Stretch"
                       VerticalAlignment="Top" TextAlignment="Left" TextWrapping="Wrap"
                       Text="{Binding Prompt, Mode=OneWay, RelativeSource={RelativeSource FindAncestor,  AncestorType={x:Type local:ProgressMonitorImplementationControl}}}" />
            <ProgressBar Name="PART_ProgressBar" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center"
                         Orientation="Horizontal" Minimum="0" Maximum="100" Height="32" Panel.ZIndex="0"
                         Value="{Binding Progress, Mode=OneWay, RelativeSource={RelativeSource FindAncestor,  AncestorType={x:Type local:ProgressMonitorImplementationControl}}}" 
                         IsIndeterminate="{Binding ProgressBarStyle, Mode=OneWay, Converter={StaticResource CompareConverter}, ConverterParameter={StaticResource Indefinite}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ProgressMonitorImplementationControl}}}" />
            <TextBlock Name="PART_ProgressInfo" Grid.Column="0" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center"
                       TextAlignment="Center" TextWrapping="NoWrap"  Background="Transparent" Panel.ZIndex="1"
                       Text="{Binding ProgressInfo, Mode=OneWay, RelativeSource={RelativeSource FindAncestor,  AncestorType={x:Type local:ProgressMonitorImplementationControl}}}"
            />
            <TextBlock Name="PART_Info" Grid.Column="0" Grid.Row="2" HorizontalAlignment="Stretch" VerticalAlignment="Top"
                       TextAlignment="Center" TextWrapping="Wrap"
                       Text="{Binding Information, Mode=OneWay, RelativeSource={RelativeSource FindAncestor,  AncestorType={x:Type local:ProgressMonitorImplementationControl}}}" />
            <Button Name="PART_Cancel" Grid.Column="0" Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center"
                    Content="{x:Static WPF:Dialogs.Cancel}"
                    Command="{x:Static local:ProgressMonitorImplementationControl.CancelCommand}"
                    IsEnabled="{Binding CancelEnabled, Mode=OneWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ProgressMonitorImplementationControl}}}" />
        </Grid>
        <ControlTemplate.Triggers>
            <Trigger Property="CancelPending" Value="True">
                <Setter Property="Content" TargetName="PART_Cancel" Value="{x:Static WPF:Dialogs.PleaseWait}"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style TargetType="{x:Type local:ProgressMonitorImplementationControl}">
        <Setter Property="VerticalAlignment" Value="Stretch"/>
        <Setter Property="HorizontalAlignment" Value="Stretch"/>
        <Setter Property="Template" Value="{StaticResource ProgressMonitorImplementationControlDefaultTemplate}"/>
        <Setter Property="Prompt" Value="{Binding Prompt, Mode=OneWay}"/>
        <Setter Property="Information" Value="{Binding Information, Mode=OneWay}"/>
        <Setter Property="Title" Value="{Binding Title, Mode=OneWay}"/>
        <Setter Property="Progress" Value="{Binding Progress, Mode=OneWay}"/>
        <Setter Property="ProgressBarStyle" Value="{Binding ProgressBarStyle, Mode=OneWay}"/>
        <Setter Property="CancelEnabled" Value="{Binding CancelEnabled, Mode=OneWay}"/>
        <Setter Property="CancelPending" Value="{Binding CancelPending, Mode=OneWay}"/>
        <Setter Property="ProgressInfo" Value="{Binding ProgressInfo, Mode=OneWay}"/>
        <Setter Property="IsTabStop" Value="False"/>
        <Setter Property="Focusable" Value="False"/>
    </Style>
</ResourceDictionary>